package com.palm.hubo2o.view;

import android.content.Context;
import android.support.v7.preference.DialogPreference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.widget.Button;

import com.palm.hubo2o.R;

/**
 * Created by wongqi on 16/6/22.
 */
public class AlertDialogPreference extends DialogPreference {

    public AlertDialogPreference(Context context) {
        super(context);
        init(context, null);
    }

    public AlertDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context, null);

    }

    public AlertDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, null);

    }

    public AlertDialogPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, null);

    }

    private void init(Context context, AttributeSet attrs) {
        setLayoutResource(R.layout.preference_alert_dialog);
    }

    @Override
    public void onBindViewHolder(PreferenceViewHolder holder) {
        super.onBindViewHolder(holder);
        holder.setDividerAllowedBelow(false);
        Button button = (Button) holder.findViewById(R.id.button);
        button.setText(getTitle());
    }


}
